using System;
using SysGeneric = System.Collections.Generic;
using System.Text;
using Generic.DataStructures;
using NUnit.Framework;

namespace Generics.Net.Tests
{
    [TestFixture]
    public class LinkedStackTester
    {
        IStack<int> _stack;
        public LinkedStackTester()
        {
            Initialize();
        }

        [TestFixtureSetUp]
        public void Initialize()
        {
            _stack = new LinkedStack<int>(10);
            _stack.Push(10);
            _stack.Push(20);
            _stack.Push(30);
            _stack.Push(40);
            _stack.Push(50);
            _stack.Push(60);
            _stack.Push(70);
            _stack.Push(80);
            _stack.Push(90);
            _stack.Push(100);
            
        }

        [Test]
        public void Push()
        {
            int count = _stack.Count;
            _stack.Push(1000);
            Assert.AreEqual(_stack.Count, count+1);
            Assert.AreEqual(_stack.Top, 1000);            
        }

        [Test]
        public void Pop()
        {
            int count = _stack.Count;
            int top = _stack.Top;
            Assert.AreEqual(top, _stack.Pop());
            Assert.AreEqual(_stack.Count, count-1);
        }

        [Test]
        public void FixedSized_Full_Empty()
        {
            _stack = new Stack<int>(5);
            _stack.FixedSize = true;
            for (int index = 1; index < 10; index++)
            {
                if (!_stack.IsFull)
                    _stack.Push(index * 100);
            }
            Assert.AreEqual(_stack.Count, 5);
            Assert.AreEqual(_stack.Top, 500);
            _stack.Clear();
            Assert.AreEqual(0, _stack.Count);
            //Reinitializing for other tests
            Initialize();            
        }
    }
}
